/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

/* Navigation */
.navbar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem 2rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
}

.nav-title {
    font-size: 1.5rem;
    font-weight: 600;
}

.nav-buttons {
    display: flex;
    gap: 1rem;
}

/* Main content */
.main-content {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 2rem;
}

/* Status cards */
.status-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.card {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.card.failed-tasks {
    border-left: 4px solid #f44336;
    background: linear-gradient(135deg, #fff 0%, #ffebee 100%);
}

.card.failed-tasks:hover {
    background: linear-gradient(135deg, #ffebee 0%, #ffcdd2 100%);
}

.card h3 {
    color: #666;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-number {
    font-size: 2.5rem;
    font-weight: bold;
    color: #667eea;
    margin-bottom: 0.25rem;
}

.stat-label {
    color: #888;
    font-size: 0.8rem;
}

/* Tab navigation */
.tab-navigation {
    display: flex;
    background: white;
    border-radius: 8px 8px 0 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 0;
    overflow: hidden;
}

.tab-button {
    flex: 1;
    padding: 1rem 2rem;
    background: none;
    border: none;
    font-size: 1rem;
    font-weight: 500;
    color: #666;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 3px solid transparent;
}

.tab-button:hover {
    background: #f8f9fa;
    color: #333;
}

.tab-button.active {
    color: #667eea;
    border-bottom-color: #667eea;
    background: #f8f9fa;
}

/* Tab content */
.tab-content {
    background: white;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    overflow: hidden;
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

/* Tasks section */
.tasks-section, .tab-pane {
    background: white;
    border-radius: 8px;
    overflow: hidden;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e0e0e0;
}

.section-header h2 {
    margin: 0;
    color: #333;
    font-size: 1.5rem;
}

.section-description {
    margin: 0.5rem 0 0 0;
    color: #666;
    font-size: 0.9rem;
    font-style: italic;
}

.filter-controls select {
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
}

.tasks-container {
    padding: 1rem;
}

.task-item {
    display: flex;
    justify-content: between;
    align-items: center;
    padding: 1rem;
    border: 1px solid #eee;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.task-item:hover {
    background-color: #f8f9fa;
    border-color: #667eea;
}

.task-info {
    flex: 1;
}

.task-name {
    font-weight: 600;
    color: #333;
    margin-bottom: 0.25rem;
}

.task-id {
    font-family: monospace;
    font-size: 0.8rem;
    color: #666;
    margin-bottom: 0.25rem;
}

.task-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.8rem;
    color: #888;
}

.task-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Task status badges */
.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-active {
    background-color: #4caf50;
    color: white;
}

.status-expired {
    background-color: #ff9800;
    color: white;
}

.status-failed {
    background-color: #f44336;
    color: white;
}

/* CRS status indicators */
.crs-error-info,
.crs-success-info,
.crs-pending-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.crs-error-info {
    background-color: #ffebee;
    color: #c62828;
    border: 1px solid #ffcdd2;
}

.crs-success-info {
    background-color: #e8f5e8;
    color: #2e7d32;
    border: 1px solid #c8e6c9;
}

.crs-pending-info {
    background-color: #fff3e0;
    color: #ef6c00;
    border: 1px solid #ffcc02;
}

.crs-error-icon,
.crs-success-icon,
.crs-pending-icon {
    font-size: 1rem;
}

/* Failed task styling */
.task-failed {
    border-left: 4px solid #f44336;
    background-color: #ffebee;
}

.task-failed:hover {
    background-color: #ffcdd2;
}

/* CRS error details */
.crs-error-details {
    margin-top: 0.5rem;
    padding: 0.5rem;
    background-color: #fff3e0;
    border: 1px solid #ffcc02;
    border-radius: 4px;
    font-size: 0.8rem;
    color: #e65100;
}

.crs-error-details strong {
    color: #bf360c;
}

/* Notification system */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 1rem 1.5rem;
    border-radius: 4px;
    color: white;
    font-weight: 500;
    z-index: 2000;
    animation: slideIn 0.3s ease;
    max-width: 400px;
    word-wrap: break-word;
}

.notification-success { 
    background-color: #4caf50; 
}

.notification-error { 
    background-color: #f44336; 
}

.notification-warning { 
    background-color: #ff9800; 
}

.notification-info { 
    background-color: #2196f3; 
}

@keyframes slideIn {
    from { 
        transform: translateX(100%); 
        opacity: 0; 
    }
    to { 
        transform: translateX(0); 
        opacity: 1; 
    }
}

/* Error message styling for backend errors */
.error-message {
    color: #D8000C !important;
    background-color: #FFBABA !important;
    border: 1px solid #D8000C !important;
    padding: 10px !important;
    margin: 10px 0 !important;
    border-radius: 5px !important;
    display: flex !important;
    align-items: center !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    font-size: 14px !important;
    line-height: 1.4 !important;
    box-shadow: 0 2px 8px rgba(216, 0, 12, 0.15) !important;
}

.error-message::before {
    content: '⚠' !important;
    font-size: 20px !important;
    margin-right: 10px !important;
    flex-shrink: 0 !important;
}

/* Make dashboard stats clickable */
.task-stats {
    display: flex;
    gap: 1rem;
    font-size: 0.8rem;
    color: #666;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-primary {
    background-color: #667eea;
    color: white;
}

.btn-primary:hover {
    background-color: #5a6fd8;
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background-color: #5a6268;
}

.btn-success {
    background-color: #28a745;
    color: white;
}

.btn-success:hover {
    background-color: #218838;
}

.btn-danger {
    background-color: #dc3545;
    color: white;
}

.btn-danger:hover {
    background-color: #c82333;
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    width: 90%;
    max-width: 700px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-large {
    max-width: 1000px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid #eee;
}

.modal-header h2 {
    margin: 0;
    color: #333;
}

.close {
    color: #aaa;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close:hover {
    color: #000;
}

/* Form styles */
form {
    padding: 1.5rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #333;
}

.form-group input[type="text"],
.form-group input[type="url"],
.form-group input[type="number"] {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
}

.form-group input[type="text"]:focus,
.form-group input[type="url"]:focus,
.form-group input[type="number"]:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.form-group input[type="checkbox"] {
    margin-right: 0.5rem;
}

.form-buttons {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #eee;
}

/* Detail content */
.detail-section {
    margin-bottom: 1.5rem;
}

.detail-section h3 {
    color: #333;
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.detail-label {
    font-weight: 500;
    color: #666;
}

.detail-value {
    color: #333;
    font-family: monospace;
    font-size: 0.9rem;
}

.artifacts-list {
    display: grid;
    gap: 0.5rem;
}

.artifact-item {
    padding: 0.75rem;
    background-color: #f8f9fa;
    border-radius: 4px;
    border-left: 3px solid #667eea;
}

.artifact-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.artifact-id {
    font-family: monospace;
    font-size: 0.8rem;
    color: #666;
}

.artifact-timestamp {
    font-size: 0.8rem;
    color: #888;
}

.artifact-content {
    font-family: monospace;
    font-size: 0.8rem;
    background-color: white;
    padding: 0.5rem;
    border-radius: 3px;
    white-space: pre-wrap;
    max-height: 200px;
    overflow-y: auto;
}

/* Loading states */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* No data states */
.no-data {
    text-align: center;
    padding: 3rem 2rem;
    color: #666;
}

.no-data-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.6;
}

.no-data-subtitle {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: #888;
}

/* Artifacts container */
.artifacts-container {
    padding: 1.5rem;
    max-height: 600px;
    overflow-y: auto;
}

.artifact-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border: 1px solid #eee;
    border-radius: 6px;
    margin-bottom: 1rem;
    background: #fafafa;
    cursor: pointer;
    transition: all 0.2s ease;
}

.artifact-list-item:hover {
    background: #f0f0f0;
    border-color: #ddd;
    transform: translateY(-1px);
}

.artifact-info {
    flex: 1;
}

.artifact-task-name {
    font-weight: 500;
    color: #333;
    margin-bottom: 0.25rem;
}

.artifact-meta {
    font-size: 0.9rem;
    color: #666;
    display: flex;
    gap: 1rem;
}

.artifact-timestamp {
    font-size: 0.8rem;
    color: #888;
}

.download-button {
    padding: 0.5rem 1rem;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s ease;
}

.download-button:hover {
    background: #5a6bd8;
}

.artifact-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    min-width: 200px;
}

/* Force button styles with maximum specificity */
.artifact-actions .approve-button,
button.approve-button {
    padding: 0.5rem 1rem !important;
    background-color: #10b981 !important;
    background: #10b981 !important;
    color: white !important;
    border: none !important;
    border-radius: 4px !important;
    cursor: pointer !important;
    font-size: 0.9rem !important;
    font-weight: 500 !important;
    transition: background 0.2s ease !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) !important;
    min-width: 80px !important;
    display: inline-block !important;
    text-decoration: none !important;
}

.artifact-actions .approve-button:hover,
button.approve-button:hover {
    background-color: #059669 !important;
    background: #059669 !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15) !important;
}

.artifact-actions .reject-button,
button.reject-button {
    padding: 0.5rem 1rem !important;
    background-color: #ef4444 !important;
    background: #ef4444 !important;
    color: white !important;
    border: none !important;
    border-radius: 4px !important;
    cursor: pointer !important;
    font-size: 0.9rem !important;
    font-weight: 500 !important;
    transition: background 0.2s ease !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) !important;
    min-width: 80px !important;
    display: inline-block !important;
    text-decoration: none !important;
}

.artifact-actions .reject-button:hover,
button.reject-button:hover {
    background-color: #dc2626 !important;
    background: #dc2626 !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15) !important;
}

.status-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: uppercase;
}

.status-badge.status-accepted {
    background: #fef3c7;
    color: #92400e;
}

.status-badge.status-passed {
    background: #d1fae5;
    color: #065f46;
}

.status-badge.status-failed {
    background: #fee2e2;
    color: #991b1b;
}

/* Additional button improvements */
.artifact-actions .approve-button:active,
button.approve-button:active,
.artifact-actions .reject-button:active,
button.reject-button:active {
    transform: translateY(1px) !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1) !important;
}

.artifact-actions .approve-button:focus,
button.approve-button:focus,
.artifact-actions .reject-button:focus,
button.reject-button:focus {
    outline: 2px solid #3b82f6 !important;
    outline-offset: 2px !important;
}

/* Additional specificity for any potential conflicts */
.artifact-list-item .artifact-actions .approve-button,
.artifact-list-item .artifact-actions .reject-button {
    background-image: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
}

/* Global button reset to prevent browser defaults */
button.approve-button,
button.reject-button {
    margin: 0 !important;
    padding: 0.5rem 1rem !important;
    background: none !important;
    background-color: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    font: inherit !important;
    line-height: normal !important;
    overflow: visible !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
}

/* Then apply our specific styles */
button.approve-button {
    background-color: #10b981 !important;
    background: #10b981 !important;
    color: white !important;
    border-radius: 4px !important;
    cursor: pointer !important;
    font-size: 0.9rem !important;
    font-weight: 500 !important;
    transition: background 0.2s ease !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) !important;
    min-width: 80px !important;
}

button.reject-button {
    background-color: #ef4444 !important;
    background: #ef4444 !important;
    color: white !important;
    border-radius: 4px !important;
    cursor: pointer !important;
    font-size: 0.9rem !important;
    font-weight: 500 !important;
    transition: background 0.2s ease !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) !important;
    min-width: 80px !important;
}

/* Responsive design */
@media (max-width: 768px) {
    .nav-container {
        flex-direction: column;
        gap: 1rem;
    }
    
    .main-content {
        padding: 0 1rem;
    }
    
    .status-cards {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .modal-content {
        margin: 2% auto;
        width: 95%;
    }
    
    .task-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .task-meta {
        flex-wrap: wrap;
    }
}

/* Hexdump and patch preview styles */
.hex-preview {
    font-family: 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.4;
    background: #1e1e1e !important;
    color: #d4d4d4;
    padding: 1rem !important;
    border-radius: 4px;
    overflow-x: auto;
}

.patch-preview {
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.4;
    background: #f8f8f8 !important;
    color: #333;
    padding: 0.5rem !important;
    border-radius: 4px;
    max-height: 200px;
    overflow-y: auto;
}